package edu.sjsu.cmpe282.dto;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import edu.sjsu.cmpe282.domain.Product;

public class ProductDao {

	 Statement stmt = null;
	    DBConnection db = new DBConnection();
	    Connection conn= db.getConnection();
	
	  public ProductDao()
	  {}
	  public boolean addProduct(Product product)
	  {
		  try {
		 stmt = conn.createStatement();
		 String query = "INSERT INTO `cloudservices`.`ProductDetails` (`CatalogID`, `Productname`, `productDesc`, `productPrice`,`Qty`) VALUES ('" + product.getCatalogID() + "', '" + product.getProductName()+ "', '" + product.getProductDesc() + "', '" + product.getPrice() + "', '" + product.getQty()+ "');";
		 stmt.executeUpdate(query);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		  return true;
	  }
	  
}
